package cn.sycoder.config;

import cn.sycoder.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@ComponentScan("cn.sycoder.interceptor")
public class SpringMvcConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                // 设置放行路径
                .excludePathPatterns(
                        "/api/login",
//                        "/item",
//                        "/api/**", // 用户管理
//                        "/api/Dept/*", // 公司管理
//                        "/api/Role/*", // 角色管理
                        "/test",
                        "/swagger-ui.html",
                        "/v2/api-docs",
                        "/swagger-resources/**");
    }
}
